package housing.task2.stale.fileIO;

import java.util.StringTokenizer;

public enum HumanReadableFormat {
    CSV, JSON, YAML;

    public static HumanReadableFormat extractExtension(String dest) {
        String[] fileNameTokens = new String[2];
        StringTokenizer st = new StringTokenizer(dest, ".");
        int i = 0;
        while (st.hasMoreTokens()) {
            fileNameTokens[i] = st.nextToken();
            ++i;
        }
        final int indexOfExtension = fileNameTokens.length - 1;
        return HumanReadableFormat.valueOf(fileNameTokens[indexOfExtension].toUpperCase());
    }

} // enum HumanReadableFormat